blob: 0898421d99ecab6430d9c83ddbc670237e046ebd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
import { NextRequest, NextResponse } from 'next/server';
import { getTableData } from '@/lib/oracle/db';
interface Params {
tableName: string;
}
interface ApiError {
message: string;
error?: string;
}
/**
* GET 핸들러 - 테이블 데이터 가져오기
*/
export async function GET(
request: NextRequest,
{ params }: { params: Params }
): Promise<NextResponse<{ data: any[] } | ApiError>> {
const { tableName } = params;
if (!tableName) {
return NextResponse.json(
{ message: '테이블 이름이 필요합니다.' },
{ status: 400 }
);
}
try {
const data = await getTableData(tableName);
return NextResponse.json({ data }, { status: 200 });
} catch (error: any) {
console.error('API 에러:', error);
return NextResponse.json(
{
message: '서버 에러가 발생했습니다.',
error: error.message
},
{ status: 500 }
);
}
}
|